<?php $orgAccount = $this->Session->read('org_account'); ?>
<style>
    #profile-form tbody th {
        text-align: right;
        vertical-align: middle;
    }

    #profile-image {
        padding: 10px;
        border: solid #ddd 1px;
        width: 120px;
        height: 150px;
        margin: 5px auto;
        background-size: cover;
        background-position: center;
    }

    .panel-heading .accordion-toggle {
        display: block;
    }
    
    .intl-tel-input {
        width: 100%;
    }
</style>

<form action="<?php echo $this->Html->url(array('controller' => 'organisation', 'action' => 'addMember')); ?>" method ="post" id="profile-form" class="form-horizontal" style="margin-top: 5px;">

    <div class="panel-group" id="accordionEditor">
        <div class="panel">
            <div class="panel-heading">
                <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionEditor" href="#editor_start">
                    <i class="fa fa-user"></i> Basic Information
                </a>
            </div>
            <div id="editor_start" class="panel-collapse collapse in">
                <div class="panel-body">
                    <div class="col-lg-4">
                        <table class="table table-condensed details_table">
                            <tbody>
                                <tr id="org_id_row">
                                    <th nowrap>ID Number:</th>
                                    <td colspan="3">
                                        <input type="text" name="OrganisationMember[organisation_no]" id="number" class="form-control input-sm" value='<?php echo isset($member) ? $member['OrganisationMember']['organisation_no'] : $nextID; ?>'/>
                                        <input type="hidden" name="OrganisationMember[id]" value='<?php echo isset($member) ? $member['OrganisationMember']['id'] : ''; ?>' />
                                        <input type='hidden' name='OrganisationMember[organisation_id]' value='<?php echo isset($member) ? $member['OrganisationMember']['organisation_id'] : $orgAccount['Organisation']['id']; ?>' />
                                        <input type='hidden' name='OrganisationMember[organisation_member_category_id]' value='<?php echo isset($member) ? $member['OrganisationMember']['organisation_member_category_id'] : $category['category']['id']; ?>' />
                                        <input type='hidden' name='OrganisationMember[member_id]' value='<?php echo isset($member) ? $member['OrganisationMember']['member_id'] : ''; ?>' />
                                        <!--<input type='hidden' name='OrganisationMember[status]' id="org_member_status" value='<?php echo isset($member) ? $member['OrganisationMember']['status'] : $status; ?>' />-->
                                        <input type='hidden' name='OrganisationMember[approved_by]' id='' value='<?php echo isset($member) ? $member['OrganisationMember']['approved_by'] : $orgAccount['OrganisationAccount']['id']; ?>' />
                                        <input type='hidden' name='OrganisationMember[approved]' id='' value='<?php echo isset($member) ? $member['OrganisationMember']['approved'] : 1; ?>' />
                                    </td>
                                </tr>
                                <tr>
                                    <th>Title: </th>
                                    <td colspan="3">
                                        <select name="Member[title]" class="form-control input-sm"> 
                                            <?php
                                            $titles = array('' => 'Select', 'mr' => 'Mr.', 'mrs' => 'Mrs.', 'ms' => 'Ms.', 'dr' => 'Dr.', 'prof' => 'Prof.', 'prof_dr' => 'Prof. Dr.', 'rev' => 'Rev.', 'rev_dr' => 'Rev. Dr.');

                                            foreach ($titles as $key => $value) {
                                                $selected = isset($member) && $member['Member']['title'] == $key ? 'selected' : '';
                                                echo "<option value='$key' $selected>$value</option>";
                                            }
                                            ?>
                                        </select>

                                        <input type="hidden" name="Member[id]" id="member_id" value="<?php echo isset($member) ? $member['Member']['id'] : ''; ?>" />
                                    </td>
                                </tr>

                                <tr>
                                    <th>* First Name: </th>
                                    <td colspan="3">
                                        <input type ="text" name="Member[first_name]" placeholder="First Name" id="first_name" required="" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['first_name'] : ''; ?>" />

                                    </td>
                                </tr>

                                <tr>
                                    <th nowrap>Middle Name: </th>
                                    <td colspan="3">
                                        <input type ="text" name="Member[middle_name]" placeholder="Middle Name" id="middle_name" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['middle_name'] : ''; ?>" />
                                    </td>
                                </tr>

                                <tr>
                                    <th>* Last Name: </th>
                                    <td colspan="3">
                                        <input type ="text" name="Member[last_name]" placeholder="Last Name" id="last_name" required="" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['last_name'] : ''; ?>" />
                                    </td>
                                </tr>
                                
                                <tr>
                                    <th>Maiden Name: </th>
                                    <td class='col-md-7 controls'>
                                        <input type ="text" name="Member[maiden_name]" placeholder="Maiden Name" id="maiden_name" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['maiden_name'] : ''; ?>" />
                                    </td>
                                </tr>

                                <tr>
                                    <th>Date Of Birth:</th>
                                    <td colspan="3">
                                        <input type="text" name="Member[dob]" id="birthday" class="form-control input-sm datepicker-input" data-date-format="yyyy-mm-dd" value="<?php echo isset($member) ? $member['Member']['dob'] : ''; ?>" placeholder="YYYY-MM-DD" />
                                    </td>

                                </tr>

                                <tr>
                                    <th nowrap>Marital Status:</th>
                                    <td>
                                        <select name="Member[marital_status]" class="form-control input-sm">
                                            <?php
                                            $titles = array('' => 'Select', 'single' => 'Single', 'married' => 'Married',
                                                'separated' => 'Separated', 'divorced' => 'Divorced', 'cohabiting' => 'Cohabiting', 'widowed' => 'Widowed');

                                            foreach ($titles as $key => $value) {
                                                $selected = isset($member) && $member['Member']['marital_status'] == $key ? 'selected' : '';
                                                echo "<option value='$key' $selected>$value</option>";
                                            }
                                            ?>
                                        </select>
                                    </td>
                                </tr>

                                <tr>
                                    <th>* Gender:</th>
                                    <td>
                                        <select name="Member[gender]" class="form-control input-sm" required="">
                                            <?php
                                            $titles = array('' => 'Select', 'male' => 'Male', 'female' => 'Female');

                                            foreach ($titles as $key => $value) {
                                                $selected = isset($member) && $member['Member']['gender'] == $key ? 'selected' : '';
                                                echo "<option value='$key' $selected>$value</option>";
                                            }
                                            ?>
                                        </select>
                                    </td>
                                </tr>


                            </tbody>
                        </table>
                    </div>

                    <div class="col-lg-6">
                        <table class="table table-condensed details_table">
                            <tr>
                                <th style="vertical-align: top;" width='100'>Phone Numbers:</th>
                                <td style="vertical-align: top;">
                                    <div class='row'>
                                        <div class="col-lg-10" id="phone_numbers_block" style='padding-right: 0px;'>
                                            <?php
                                            if (isset($member) && count($member['Member']['MemberPhoneNumber']) > 0) {
                                                for ($i = 0; $i < count($member['Member']['MemberPhoneNumber']); $i++) {
                                                    $number = $member['Member']['MemberPhoneNumber'][$i];
                                                    ?>
                                                    <div class="input-group m-b-xs">
                                                        <div class="input-group-btn phone_type">
                                                            <button type="button" class="btn btn-white btn-sm dropdown-toggle" data-toggle="dropdown">
                                                                <?php 
                                                                $icon = "fa-mobile";
                                                                switch($number['type']) {
                                                                    case 'mobile': $icon = 'fa-mobile'; break;
                                                                    case 'home': $icon = 'fa-home'; break;
                                                                    case 'office': $icon = 'fa-phone'; break;
                                                                }
                                                                ?>
                                                                <span class="dropdown-label" data-placeholder="Please select"><i class='fa <?php echo $icon; ?>'></i></span> 
                                                                <span class="caret"></span>
                                                            </button>
                                                            <ul class="dropdown-menu dropdown-select">
                                                                <li class="<?php $number['type'] == 'mobile' ? 'active' : ''; ?>">
                                                                    <a href="#">
                                                                        <input type="radio" name="Member[MemberPhoneNumber][<?php echo $i; ?>][type]" value="mobile" <?php echo $number['type'] == 'mobile' ? 'checked' : ''; ?> />
                                                                        <span class="html"><i class='fa fa-mobile'></i></span> Mobile
                                                                    </a>
                                                                </li>
                                                                <li class="<?php $number['type'] == 'home' ? 'active' : ''; ?>">
                                                                    <a href="#">
                                                                        <input type="radio" name="Member[MemberPhoneNumber][<?php echo $i; ?>][type]" value="home" <?php echo $number['type'] == 'homd' ? 'checked' : ''; ?> />
                                                                        <span class="html"><i class='fa fa-home'></i></span> Home
                                                                    </a>
                                                                </li>
                                                                <li class="<?php $number['type'] == 'office' ? 'active' : ''; ?>">
                                                                    <a href="#">
                                                                        <input type="radio" name="Member[MemberPhoneNumber][<?php echo $i; ?>][type]" value="office" <?php echo $number['type'] == 'office' ? 'checked' : ''; ?> />
                                                                        <span class="html"><i class='fa fa-phone'></i></span> Office
                                                                    </a>
                                                                </li>
                                                            </ul>
                                                        </div>
                                                        
                                                        <input type="text" name="Member[MemberPhoneNumber][<?php echo $i; ?>][number]" class="form-control input-sm phone_number" value="<?php echo $number['number']; ?>" />
                                                        <input type="hidden" class="phone_number_id" name="Member[MemberPhoneNumber][<?php echo $i; ?>][id]" value="<?php echo $number['id']; ?>" />
                                                        <span class="input-group-addon remove_phone_number">
                                                            <a href="#"><i class='fa fa-minus'></i></a>
                                                        </span>
                                                    </div>
                                                    <?php
                                                }
                                            } else {
                                                ?>
                                                <div class="input-group m-b-xs">
                                                    <div class="input-group-btn phone_type">
                                                        <button type="button" class="btn btn-white btn-sm dropdown-toggle" data-toggle="dropdown">
                                                            <span class="dropdown-label" data-placeholder="Please select"><i class='fa fa-mobile'></i> </span>
                                                            
                                                            <span class="caret"></span>
                                                        </button>
                                                        <ul class="dropdown-menu dropdown-select">
                                                            <li class="active"><a href="#"><input type="radio" name="Member[MemberPhoneNumber][0][type]" value="mobile" checked="" /><span class="html"><i class='fa fa-mobile'></i></span> Mobile</a></li>
                                                            <li><a href="#"><input type="radio" name="Member[MemberPhoneNumber][0][type]" value="home" /><span class="html"><i class='fa fa-home'></i></span> Home</a></li>
                                                            <li><a href="#"><input type="radio" name="Member[MemberPhoneNumber][0][type]" value="office" /><span class="html"><i class='fa fa-phone'></i></span> Office</a></li>
                                                        </ul>
                                                    </div>
                                                    
                                                    <input type="text" name="Member[MemberPhoneNumber][0][number]" class="form-control input-sm phone_number" value=""/>
                                                    <span class="input-group-addon remove_phone_number">
                                                        <a href="#"><i class='fa fa-minus'></i></a>
                                                    </span>
                                                </div>
                                                <?php
                                            }
                                            ?>

                                        </div>
                                        <div class="col-lg-2" style='padding-right: 0px;'>
                                            <div class="m-t-xs"><a href="#" class="text-info" id="add_phone_number"><i class="fa fa-plus"></i></a></div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <!--<tr>
                                <th>Mobile Number:</th>
                                <td><input type="text" name="Member[mobile_number]" id="mobile_number" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['mobile_number'] : ''; ?>"/></td>
                            </tr>

                            <tr>
                                <th>Office Number:</th>
                                <td><input type="text" name="Member[office_number]" id="office_number" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['office_number'] : ''; ?>" /></td>
                            </tr>-->

                            <tr>
                                <th style="vertical-align: top;">Email Addresses: </th>
                                <td colspan="3" style="vertical-align: top;">
                                    <div class='row'>
                                        <div class="col-sm-10" id="emails_block" style="padding-right: 0px;">
                                            <?php
                                            if (isset($member) && count($member['Member']['MemberEmail']) > 0) {
                                                for ($i = 0; $i < count($member['Member']['MemberEmail']); $i++) {
                                                    $email = $member['Member']['MemberEmail'][$i];
                                                    ?>
                                                    <div class="input-group m-b-xs">
                                                        <input type="text" name="Member[MemberEmail][<?php echo $i; ?>][email]" class="form-control input-sm email" value="<?php echo $email['email']; ?>" />
                                                        <input type="hidden" class="email_id" name="Member[MemberEmail][<?php echo $i; ?>][id]" value="<?php echo $email['id']; ?>" />
                                                        <span class="input-group-addon remove_email">
                                                            <a href="#"><i class='fa fa-minus'></i></a>
                                                        </span>
                                                    </div>
                                                    <?php
                                                }
                                            } else {
                                                ?>
                                                <div class="input-group m-b-xs">
                                                    <input type="text" name="Member[MemberEmail][0][email]" class="form-control input-sm email" value=""/>
                                                    <span class="input-group-addon remove_email">
                                                        <a href="#"><i class='fa fa-minus'></i></a>
                                                    </span>
                                                </div>
                                                <?php
                                            }
                                            ?>

                                        </div>
                                        <div class="col-sm-2" style="padding-right: 5px;">
                                            <div class="m-t-xs">
                                                <a href="#" class="text-info" id="add_email"><i class="fa fa-plus"></i> </a>
                                            </div>
                                        </div>
                                    </div>

<!--<input type="email" name="Member[email]" id="email_address" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['email'] : ''; ?>" />-->
                                </td>
                            </tr>
                            <tr>
                                <th>Postal Address: </th>
                                <td colspan="3"><input type="text" name="Member[address]" id="post_add" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['address'] : ''; ?>" /></td>
                            </tr>
                            <tr>
                                <th>Website: </th>
                                <td colspan="3"><input type="url" name="Member[website]" id="website" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['website'] : ''; ?>" /></td>
                            </tr>
                            <!--<tr>
                                <td>Social Profiles:</td>
                                <td colspan="3">
                                    <label class="label label-info" style="display: inline">Facebook</label>
                                    <label class="label label-info" style="display: inline">Twitter</label>
                                </td>
                            </tr>-->

                        </table>
                    </div>

                    <div class="col-lg-2">
                        <table>
                            <tr>
                                <td>
                                    <!--                                    <div id="profile-image"></div>-->
                                    <?php
                                    if (isset($member['OrganisationMemberImage']['MemberImage']['id']) && $member['OrganisationMemberImage']['MemberImage']['id'] != null) {
                                        $src = $this->Html->url($member['OrganisationMemberImage']['MemberImage']['url']);
                                    }
                                    ?>

                                    <div id="profile-image" style="<?php echo isset($src) ? "background-image: url($src);" : ''; ?>">
                                        <input type="hidden" name="OrganisationMemberImage[member_image_id]" id="member_image_id" value="<?php echo isset($member['OrganisationMemberImage']['member_image_id']) ? $member['OrganisationMemberImage']['member_image_id'] : ''; ?>" />
                                        <input type="hidden" name="OrganisationMemberImage[organisation_id]" value="<?php echo isset($member['OrganisationMemberImage']['organisation_id']) ? $member['OrganisationMemberImage']['organisation_id'] : $orgAccount['Organisation']['id']; ?>" />
                                        <input type="hidden" name="OrganisationMemberImage[id]" id="organisation_member_image_id" value="<?php echo isset($member['OrganisationMemberImage']['id']) ? $member['OrganisationMemberImage']['id'] : ''; ?>" />
                                        <!--<input type="hidden" name="Member[MemberImage][0][id]" id="image_id" value="<?php echo isset($member['OrganisationMemberImage']['member_image_id']) ? $member['OrganisationMemberImage']['member_image_id'] : ''; ?>" />-->
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <button class="btn btn-sm btn-default btn-rounded" id="upload-btn"><i class="fa fa-cloud-upload"></i> Upload New</button>
                                </td>
                            </tr>
                        </table>
                    </div>

                </div>
            </div>
        </div>

        <?php if (isset($category['settings']['additional_profile_info']) && $category['settings']['additional_profile_info'] == "1") { ?>
            <div class="panel" id="extra_profile_info">
                <div class="panel-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionEditor" href="#editor_profile_extra">
                        <i class="fa fa-plus"></i> Additional Information
                    </a>
                </div>
                <div id="editor_profile_extra" class="panel-collapse collapse">
                    <div class="panel-body">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <div class="col-lg-5 control-label">Place of Birth:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[place_of_birth]" id="pob" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['place_of_birth'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-5 control-label">Hometown:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[home_town]" id="hometown" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['home_town'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-5 control-label">Tribe:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[tribe]" id="tribe" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['tribe'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-5 control-label">Nationality:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[nationality]" id="nationality" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['nationality'] : ''; ?>" />
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-5 control-label">Educational Background:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[educational_bg]" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['educational_bg'] : ''; ?>" />
                                    <!--<select name="Member[educational_bg]" class="form-control input-sm">
                                    <?php
                                    $titles = array('' => 'Select', 'Junior High' => 'Junior High', 'Senior High' => 'Senior High', 'Diploma' => 'Diploma',
                                        'Polytechnic' => 'Polytechnic', 'Training College' => 'Training College', 'University (1st Degree)' => 'University (1st Degree)',
                                        'Masters Degree' => 'Masters Degree', 'Doctorate' => 'Doctorate', 'Professorate' => 'Professorate');

                                    foreach ($titles as $key => $value) {
                                        $selected = isset($member) && $member['Member']['educational_bg'] == $key ? 'selected' : '';
                                        echo "<option value='$key' $selected>$value</option>";
                                    }
                                    ?>
                                    </select>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-5 control-label">Field of Study:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[field_of_study]" id="fos" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['field_of_study'] : ''; ?>" />
                                </div>
                            </div>

                            
                        </div>

                        <div class="col-lg-6">
                            
                            <div class="form-group">
                                <div class="col-lg-5 control-label">Employment Status:</div>
                                <div class="col-lg-7 controls">
                                    <select name="Member[employment_status]" class="form-control input-sm">
                                        <?php
                                        $em_statuses = array(
                                            '' => 'Select', 
                                            'employer' => 'Employer', 
                                            'employed' => 'Employed', 
                                            'unemployed' => 'Unemployed',
                                            'retired' => 'Retired'
                                        );

                                        foreach ($em_statuses as $key => $value) {
                                            $selected = isset($member) && strtolower($member['Member']['employment_status']) == $key ? 'selected' : '';
                                            echo "<option value='$key' $selected>$value</option>";
                                        }
                                        ?>
                                    </select>
                                </div>

                            </div>

                            <div class="form-group">
                                <div class="col-lg-5 control-label">Profession:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[profession]" id="profession" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['profession'] : ''; ?>"/>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-5 control-label">Occupation:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[occupation]" id="occupation" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['occupation'] : ''; ?>"/>
                                </div>
                            </div>


                            <div class="form-group">
                                <div class="col-lg-5 control-label">Position:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[position]" id="position" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['position'] : ''; ?>" />
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-5 control-label">Social Security No.:</div>
                                <div class="col-lg-7 controls">
                                    <input type="text" name="Member[social_security_no]" id="social_security_no" class="form-control input-sm" value="<?php echo isset($member) ? $member['Member']['social_security_no'] : ''; ?>" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
        
        <?php if (isset($category['settings']['location_info']) && $category['settings']['location_info'] == "1") { ?>
            <div class="panel" id="location_info">
                <div class="panel-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionEditor" href="#editor_two">
                        <i class="fa fa-home"></i> Location Information
                    </a>
                </div>
                <div id="editor_two" class="panel-collapse collapse">
                    <div class="panel-body">
                        <div class="col-lg-6">
                            <h6 class="font-bold text-info">Company Information</h6>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">Name:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" class="form-control input-sm" name="Member[business_name]" id="bus_add" value="<?php echo isset($member) ? $member['Member']['business_name'] : ''; ?>" />
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-4 control-label">Address:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" class="form-control input-sm" name="Member[business_address]" id="bus_add" value="<?php echo isset($member) ? $member['Member']['business_address'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">Region / State:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[business_region]" id="region" class="form-control input-sm input-s-sm" value="<?php echo isset($member) ? $member['Member']['business_region'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">City:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[business_city]" class="form-control input-sm input-s-sm" id="city" value="<?php echo isset($member) ? $member['Member']['business_city'] : ''; ?>" />
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-4 control-label">District:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[business_district]" id="district" class="form-control input-sm input-s" value="<?php echo isset($member) ? $member['Member']['business_district'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">Zip / Post Code:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[business_zip_code]" class="form-control input-sm input-s-xs" maxlength="5" value="<?php echo isset($member) ? $member['Member']['business_zip_code'] : ''; ?>" />
                                </div>
                            </div>
                        </div>

                        <div class="col-lg-6">
                            <h6 class="font-bold text-info">Residential Address</h6>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">Address:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" class="form-control input-sm" name="Member[residential_address]" id="res_add" value="<?php echo isset($member) ? $member['Member']['residential_address'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">Region / State:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[residential_region]" id="region" class="form-control input-sm input-s-sm" value="<?php echo isset($member) ? $member['Member']['residential_region'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">City:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[residential_city]" class="form-control input-sm input-s-sm" id="city" value="<?php echo isset($member) ? $member['Member']['residential_city'] : ''; ?>" />
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <div class="col-lg-4 control-label">District:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[residential_district]" id="district" class="form-control input-sm input-s" value="<?php echo isset($member) ? $member['Member']['residential_district'] : ''; ?>" />
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-lg-4 control-label">Zip / Post Code:</div>
                                <div class="col-lg-8 controls">
                                    <input type="text" name="Member[residential_zip_code]" class="form-control input-sm input-s-xs" maxlength="5" id="zip_code" value="<?php echo isset($member) ? $member['Member']['residential_zip_code'] : ''; ?>" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>

        <?php if (isset($category['settings']['family_info']) && $category['settings']['family_info'] == "1") { ?>
            <div class="panel">
                <div class="panel-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionEditor" href="#family_info">
                        <i class="fa fa-group"></i> Family Information
                    </a>
                </div>
                <div id="family_info" class="panel-collapse collapse">
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="control-label col-lg-1">
                                Father:
                            </div>
                            <div class="controls form-inline col-lg-11">
                                <?php
                                $father = isset($member) && isset($member['Member']['MemberParent'][0]) ? $member['Member']['MemberParent'][0] : null;
                                ?>
                                <input type="text" class="form-control input-sm input-s" placeholder="Father's Name" name="Member[MemberParent][0][name]" value="<?php echo isset($father) ? $father['name'] : ''; ?>" />
                                <input type='text' class='form-control input-sm input-s-sm datepicker-input' data-date-format="yyyy-mm-dd" placeholder="Birth Date" name="Member[MemberParent][0][dob]" value="<?php echo isset($father) ? $father['dob'] : ''; ?>" />
                                <label class="input-s-sm"></label>
                                <label class='input-sm input-s'>
                                    <input type='hidden' name='Member[MemberParent][0][is_alive]' value='1' />
                                    <input type='checkbox' name='Member[MemberParent][0][is_alive]' value='0' <?php echo isset($father) && $father['is_alive'] == '0' ? 'checked' : ''; ?> />
                                    <span>Deceased</span>
                                </label>

                                <input type='hidden' name='Member[MemberParent][0][member_id]' value='<?php echo isset($member) ? $member['Member']['id'] : ''; ?>' />
                                <input type='hidden' name='Member[MemberParent][0][id]' value='<?php echo isset($father) ? $father['id'] : ''; ?>' />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="control-label col-lg-1">
                                Mother:
                            </div>
                            <div class="controls form-inline col-lg-11">
                                <?php
                                $mother = isset($member) && isset($member['Member']['MemberParent'][1]) ? $member['Member']['MemberParent'][1] : null;
                                ?>
                                <input type="text" class="form-control input-sm input-s" placeholder="Mother's Name" name="Member[MemberParent][1][name]" value="<?php echo isset($mother) ? $mother['name'] : ''; ?>" />
                                <input type='text' class='form-control input-sm input-s-sm datepicker-input' data-date-format="yyyy-mm-dd" placeholder="Birth Date" name="Member[MemberParent][1][dob]" value="<?php echo isset($mother) ? $mother['dob'] : ''; ?>" />
                                <label class="input-s-sm"></label>
                                <label class='input-sm input-s'>
                                    <input type='hidden' name='Member[MemberParent][1][is_alive]' value='1' />
                                    <input type='checkbox' name='Member[MemberParent][1][is_alive]' value='0' <?php echo isset($mother) && $mother['is_alive'] == '0' ? 'checked' : ''; ?> />
                                    <span>Deceased</span>
                                </label>

                                <input type='hidden' name='Member[MemberParent][1][member_id]' value='<?php echo isset($member) ? $member['Member']['id'] : ''; ?>' />
                                <input type='hidden' name='Member[MemberParent][1][id]' value='<?php echo isset($mother) ? $mother['id'] : ''; ?>' />
                            </div>
                        </div>

                        <div class="form-group">
                            <?php
                            $spouse = isset($member) && isset($member['Member']['MemberSpouse'][0]) ? $member['Member']['MemberSpouse'][0] : null;
                            ?>
                            <div class="control-label col-lg-1">
                                Spouse:
                            </div>
                            <div class="controls form-inline col-lg-11">
                                <input type="text" class="form-control input-sm input-s" placeholder="Spouse's Name" name="Member[MemberSpouse][0][name]" value="<?php echo isset($spouse) ? $spouse['name'] : ''; ?>" />
                                <input type='text' class='form-control input-sm input-s-sm datepicker-input' data-date-format="yyyy-mm-dd" placeholder="Birth Date" name="Member[MemberSpouse][0][dob]" value="<?php echo isset($spouse) ? $spouse['dob'] : ''; ?>" />
                                <select name="Member[MemberSpouse][0][gender]" class="form-control input-sm input-s-sm">
                                    <option value="">Gender</option>
                                    <option value="male" <?php echo isset($spouse) && $spouse['gender'] == 'male' ? 'selected' : ''; ?>>Male</option>
                                    <option value="female" <?php echo isset($spouse) && $spouse['gender'] == 'female' ? 'selected' : ''; ?>>Female</option>
                                </select>
                                <label class='input-sm input-s'>
                                    <input type='hidden' name='Member[MemberSpouse][0][is_alive]' value='1' />
                                    <input type='checkbox' name='Member[MemberSpouse][0][is_alive]' value='0' <?php echo isset($spouse) && $spouse['is_alive'] == '0' ? 'checked' : ''; ?> />
                                    <span>Deceased</span>
                                </label>

                                <input type='hidden' name='Member[MemberSpouse][0][member_id]' value='<?php echo isset($member) ? $member['Member']['id'] : ''; ?>' />
                                <input type='hidden' name='Member[MemberSpouse][0][id]' value='<?php echo isset($spouse) ? $spouse['id'] : ''; ?>' />
                            </div>
                        </div>

                        <div class="form-group m-t-lg">
                            <div class="control-label col-lg-1">
                                Children:
                            </div>
                            <div class="controls form-inline col-lg-11">

                                <div class='row'>
                                    <div id='children_block' class='col-lg-10'>
                                        <?php
                                        if (isset($member['Member']['MemberChild'][0])) {
                                            $i = 0;
                                            foreach ($member['Member']['MemberChild'] as $child) {
                                                ?>
                                                <div class='child_block'>
                                                    <input type="text" class="form-control input-sm input-s" placeholder="Child's Name" name='Member[MemberChild][<?php echo $i; ?>]' value='<?php echo $child['name']; ?>' />
                                                    <input type='text' class='form-control input-sm input-s-sm datepicker-input' data-date-format="yyyy-mm-dd" placeholder="Birth Date" name='Member[MemberChild][<?php echo $i; ?>][dob]' value='<?php echo $child['dob']; ?>' />
                                                    <select class="form-control input-sm input-s-sm" name='Member[MemberChild][<?php echo $i; ?>][gender]'>
                                                        <option value="">Gender</option>
                                                        <option value="male" <?php echo $child['gender'] == 'male' ? 'selected' : ''; ?>>Male</option>
                                                        <option value="female" <?php echo $child['gender'] == 'female' ? 'selected' : ''; ?>>Female</option>
                                                    </select>
                                                    <label class='input-sm input-s-sm'>
                                                        <input type='hidden' name='Member[MemberChild][<?php echo $i; ?>][is_alive]' value='1' />
                                                        <input type='checkbox' name='Member[MemberChild][<?php echo $i; ?>][is_alive]' value='0' <?php echo $child['is_alive'] == '0' ? 'checked' : null; ?> />
                                                        <span>Deceased</span>
                                                    </label>

                                                    <button type='button' class='btn btn-xs btn-danger remove_child'>
                                                        <i class='fa fa-times'></i>
                                                    </button>

                                                    <input type='hidden' name='Member[MemberChild][<?php echo $i; ?>][member_id]' value='<?php echo $child['member_id']; ?>' />
                                                    <input type='hidden' name='Member[MemberChild][<?php echo $i; ?>][id]' class='child_id' value='<?php echo $child['id']; ?>' />
                                                </div>
                                                <?php
                                                $i++;
                                            }
                                        } else {
                                            ?>

                                            <div class='child_block'>
                                                <input type="text" class="form-control input-sm input-s" placeholder="Child's Name" name='Member[MemberChild][0][name]' />
                                                <input type='text' class='form-control input-sm input-s-sm datepicker-input' data-date-format="yyyy-mm-dd" placeholder="Birth Date" name='Member[MemberChild][0][dob]' />
                                                <select class="form-control input-sm input-s-sm" name='Member[MemberChild][0][gender]'>
                                                    <option value="">Gender</option>
                                                    <option value="male">Male</option>
                                                    <option value="female">Female</option>
                                                </select>
                                                <label class='input-sm input-s-sm'>
                                                    <input type='hidden' name='Member[MemberChild][0][is_alive]' value='1' />
                                                    <input type='checkbox' name='Member[MemberChild][0][is_alive]' value='0' />
                                                    <span>Deceased</span>
                                                </label>

                                                <button type='button' class='btn btn-xs btn-danger remove_child'>
                                                    <i class='fa fa-times'></i>
                                                </button>

                                                <input type='hidden' name='Member[MemberChild][0][member_id]' value='<?php echo isset($member) ? $member['Member']['id'] : ''; ?>' />
                                                <input type='hidden' name='Member[MemberChild][0][id]' class='child_id' value='' />
                                            </div>
                                        <?php } ?>
                                    </div>

                                    <div class='child_options col-lg-2'>
                                        <button type='button' class='btn btn-white btn-sm' id='add_child_btn'>
                                            <i class="fa fa-plus"></i> Add Child
                                        </button>

                                        <input type='hidden' id='remove_child_url' value='<?php echo $this->Html->url(array('action' => 'remove_child')); ?>' />
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        <?php } ?>

        

        <?php
        if (isset($category['settings']['group_info']) && $category['settings']['group_info'] == "1" ||
                isset($category['settings']['anniversary_info']) && $category['settings']['anniversary_info'] == '1') {
            ?>
            <div class="panel" id="group_info">
                <div class="panel-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionEditor" href="#editor_three">
                        <i class="fa fa-user"></i> Groups & Dates
                    </a>
                </div>
                <div id="editor_three" class="panel-collapse collapse">
                    <div class="panel-body">

                        <?php if ($category['settings']['group_info'] == "1") { ?>
                            <div class="col-lg-6">
                                <h5>Groups Associated With</h5>

                                <table class="table table-condensed details_table">
                                    <?php
                                    $i = 0;
                                    foreach ($org_info['OrganisationGroupType'] as $group) {
                                        ?>
                                        <tr>
                                            <td width="40%" valign="middle"><?php echo $group['name']; ?>:</td>
                                            <td colspan="5">

                                                <select class="form-control input-sm input-s" name="OrganisationMember[OrganisationMemberGroup][<?php echo $i; ?>][organisation_group_id]">
                                                    <option value="">Select Option</option>
                                                    <option value="">------------------</option>

                                                    <?php
                                                    $org_group = null;

                                                    foreach ($group['OrganisationGroup'] as $subgroup) {
                                                        $value = $subgroup['id'];
                                                        $key = $subgroup['name'];

                                                        $selected = "";

                                                        if (isset($member['OrganisationMemberGroup'])) {
                                                            foreach ($member['OrganisationMemberGroup'] as $mg) {
                                                                if ($mg['organisation_group_id'] == $subgroup['id']) {
                                                                    $selected = "selected=selected";
                                                                    $org_group = $mg;
                                                                }
                                                            }
                                                        }
                                                        ?>
                                                        <option value="<?php echo $value; ?>" <?php echo $selected; ?>><?php echo $key; ?></option>
                                                    <?php } ?>
                                                </select>

                                                <input type="hidden" name="OrganisationMember[OrganisationMemberGroup][<?php echo $i; ?>][id]" value="<?php echo $org_group ? $org_group['id'] : null; ?>" />
                                                <input type="hidden" name="OrganisationMember[OrganisationMemberGroup][<?php echo $i; ?>][organisation_member_id]" value="<?php echo isset($member) ? $member['OrganisationMember']['id'] : null; ?>" />
                                                <input type="hidden" name="OrganisationMember[OrganisationMemberGroup][<?php echo $i; ?>][organisation_id]" value="<?php echo isset($member) ? $member['OrganisationMember']['organisation_id'] : $orgAccount['Organisation']['id']; ?>" />
                                            </td>
                                        </tr>
                                        <?php
                                        $i++;
                                    }
                                    ?>
                                </table>
                            </div>
                        <?php } ?>

                        <?php if ($category['settings']['anniversary_info'] == "1") { ?>
                            <div class="col-lg-6">
                                <h5>Important Dates</h5>

                                <table class="table table-condensed details_table">
                                    <?php
                                    $i = 0;
                                    foreach ($org_info['OrganisationAnniversary'] as $date) {
                                        $md_date = null;
                                        $value = null;
                                        
                                        if (isset($member['OrganisationMemberAnniversary'])) {
                                            foreach ($member['OrganisationMemberAnniversary'] as $md) {
                                                if ($md['organisation_anniversary_id'] == $date['id']) {
                                                    $value = $md['value'];
                                                    $md_date = $md;
                                                }
                                            }
                                        }
                                        ?>
                                        <tr>
                                            <td width="40%"><?php echo $date['name']; ?>:</td>
                                            <td colspan="5">
                                                <input type="hidden" name="OrganisationMember[OrganisationMemberAnniversary][<?php echo $i; ?>][id]" value="<?php echo isset($member) ? $md_date['id'] : ''; ?>" />
                                                <input type="hidden" name="OrganisationMember[OrganisationMemberAnniversary][<?php echo $i; ?>][organisation_id]" value="<?php echo isset($member) ? $member['OrganisationMember']['organisation_id'] : $orgAccount['Organisation']['id']; ?>" />
                                                <input type="hidden" name="OrganisationMember[OrganisationMemberAnniversary][<?php echo $i; ?>][organisation_member_id]" value="<?php echo isset($member) ? $member['OrganisationMember']['id'] : null; ?>" />
                                                <input type="hidden" name="OrganisationMember[OrganisationMemberAnniversary][<?php echo $i; ?>][organisation_anniversary_id]" value="<?php echo $date['id']; ?>" />
                                                <input type="date" class="form-control input-sm input-s" name="OrganisationMember[OrganisationMemberAnniversary][<?php echo $i; ?>][value]" value="<?php echo $value; ?>" />
                                            </td>
                                        </tr>
                                        <?php
                                        $i++;
                                    }
                                    ?>
                                </table>
                            </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
        <?php } ?>

        <?php if (isset($category['settings']['notes']) && $category['settings']['notes'] == "1") { ?>
            <div class="panel">
                <div class="panel-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionEditor" href="#editor_five">
                        <i class="fa fa-pencil"></i> Notes
                    </a>
                </div>
                <div id="editor_five" class="panel-collapse collapse">
                    <div class="panel-body">
                        <div class="row m-b-sm hidden">
                            <div class="col-lg-12">
                                <input type="text" name="OrganisationMemberNote[title]" class="form-control input-sm" placeholder="Note Title" value="<?php echo isset($member) ? $member['OrganisationMemberNote']['title'] : ''; ?>" />
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-12">
                                <div class="paper" style="border: solid #d8dde5 1px;">
                                    <textarea name="OrganisationMemberNote[note]" rows="3" cols="80" class="form-control input-sm" placeholder="Enter Notes Here"><?php echo isset($member) ? $member['OrganisationMemberNote']['note'] : ''; ?></textarea>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="OrganisationMemberNote[id]" value="<?php echo isset($member) ? $member['OrganisationMemberNote']['id'] : ''; ?>" />
                        <input type="hidden" name="OrganisationMemberNote[organisation_member_id]" value="<?php echo isset($member) ? $member['OrganisationMember']['id'] : ''; ?>" />
                        <input type="hidden" name="OrganisationMemberNote[organisation_id]" value="<?php echo isset($member) ? $member['OrganisationMember']['organisation_id'] : $orgAccount['Organisation']['id']; ?>" />
                        <input type="hidden" name="OrganisationMemberNote[active]" value="<?php echo isset($member) ? $member['OrganisationMemberNote']['active'] : 1; ?>" />
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>

    <div class="form-actions" style="padding-top: 10px; padding-bottom: 10px; padding-left: 110px;">
        <button type="submit" class="btn btn-sm btn-info" id="submit-btn"><i class="fa fa-save"></i> Save Changes</button>
        <button type="button" class="btn btn-sm btn-white" id="cancel-btn"><i class="fa fa-remove"></i> Cancel</button>
    </div>
</form>